﻿using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
using System.ComponentModel.DataAnnotations;

namespace bpms.Models
{
    /// <summary>
    /// 购买视图
    /// </summary>
    public class BuyViewModel
    {
        public int ProductId { get; set; }

        [ValidateNever]
        public string ProductNo { get; set; }

        [ValidateNever]
        public string ProductName { get; set; }
        public decimal Price { get; set; }
        public int Stock { get; set; }

        [Required(ErrorMessage = "数量不能为空")]
        [Range(1, int.MaxValue, ErrorMessage = "数量必须大于0")]
        [Display(Name = "数量")]
        public int Quantity { get; set; }

        [Required(ErrorMessage = "配送时间不能为空")]
        [Display(Name = "配送时间")]
        [DataType(DataType.DateTime)]
        public DateTime DeliveryTime { get; set; }
        /// <summary>
        /// 订单总价
        /// </summary>
        [Display(Name = "订单总价")]
        public decimal TotalAmount => Price * Quantity;
    }
}
